package com.itheima;

/**
 * set(...) : 存
 * get(): 取
 * remove(): 删
 *
 */
public class ThreadLocalDemo {

    private static ThreadLocal<String> LOCAL = new ThreadLocal<String>();

    public static void main(String[] args) {

        LOCAL.set("ITCAST-MAIN"); //存储 ---> 主线程

        new Thread(new Runnable() {
            @Override
            public void run() {
                LOCAL.set("ITHEIMA-SUB");

                String s = LOCAL.get();
                System.out.println("SUB: " + s);
            }
        }).start();

        String s = LOCAL.get();
        System.out.println("MAIN: "+s); //获取 ----> 主线程

    }

}
